#ifndef TC_CAL_LIB_H_
#define TC_CAL_LIB_H_

#include "templib.h"
#include "dataproc.h"
#include "correct.h"

#ifdef WIN32
typedef double tc_val_type;
#else
typedef float tc_val_type;
#endif

#ifdef __cplusplus
extern "C"
{
#endif

	typedef struct
	{
		float mV;		 
		int32_t adc_val; 
	} tc_sample_type;

	typedef struct
	{
		uint8_t err;		 
		uint8_t sample_nums; 
		uint8_t bCFEn;
		int32_t adc_val;
		tc_val_type air_temp; 

		i16_limit_type limit; 

		tc_val_type filter;

		tc_val_type coef; 

		tc_sample_type Sample[4]; 

		struct
		{
			tc_val_type f_org; 
			tc_val_type f_ctr;
			tc_val_type f_real;
			tc_val_type f_disp;
			int32_t i_ctr;
			int32_t i_disp;
			int32_t i_org;
		} result;

		struct
		{
			int32_t pb;
			int32_t pk;

			uint8_t point_len;
			void *point_list;
			
			float offset_before, offset_after;
		} correct;

		tc_val_type (*t_to_v)(tc_val_type t);
		tc_val_type (*v_to_t)(tc_val_type v);

	} tc_cal_type;

	tc_val_type R_TtoV(tc_val_type T);
	tc_val_type R_VtoT(tc_val_type mV);
	tc_val_type tc_k_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_k_cal_imap(tc_cal_type *tc);

	tc_val_type E_TtoV(tc_val_type T);
	tc_val_type E_VtoT(tc_val_type mV);
	tc_val_type tc_r_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_r_cal_imap(tc_cal_type *tc);

	tc_val_type K_TtoV(tc_val_type T);
	tc_val_type K_VtoT(tc_val_type mV);
	tc_val_type tc_e_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_e_cal_imap(tc_cal_type *tc);

	tc_val_type J_TtoV(tc_val_type T);
	tc_val_type J_VtoT(tc_val_type mV);
	tc_val_type tc_j_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_j_cal_imap(tc_cal_type *tc);

	tc_val_type S_TtoV(tc_val_type T);
	tc_val_type S_VtoT(tc_val_type mV);
	tc_val_type tc_s_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_s_cal_imap(tc_cal_type *tc);

	tc_val_type T_TtoV(tc_val_type T);
	tc_val_type T_VtoT(tc_val_type mV);
	tc_val_type tc_t_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_t_cal_imap(tc_cal_type *tc);

	tc_val_type N_TtoV(tc_val_type T);
	tc_val_type N_VtoT(tc_val_type mV);
	tc_val_type tc_n_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_n_cal_imap(tc_cal_type *tc);

	tc_val_type B_TtoV(tc_val_type T);
	tc_val_type B_VtoT(tc_val_type mV);
	tc_val_type tc_b_cal_pbpk(tc_cal_type *tc);
	tc_val_type tc_b_cal_imap(tc_cal_type *tc);

	void tc_cal_reset(tc_cal_type *obj, int32_t result);

#ifdef __cplusplus
}
#endif

#endif 
